home *** CD-ROM | disk | FTP | other *** search
/ Nothing but Tetris / Nothing but Tetris.iso / amiga / yactris / src / dbug / dbug.h < prev   
C/C++ Source or Header  |  1994-01-01  |  6KB  |  166 lines

  1. /******************************************************************************
  2.  *                                          *
  3.  *                   N O T I C E                      *
  4.  *                                          *
  5.  *              Copyright Abandoned, 1987, Fred Fish              *
  6.  *                                          *
  7.  *                                          *
  8.  *    This previously copyrighted work has been placed into the  public     *
  9.  *    domain    by  the  author  and  may be freely used for any purpose,     *
  10.  *    private or commercial.                              *
  11.  *                                          *
  12.  *    Because of the number of inquiries I was receiving about the  use     *
  13.  *    of this product in commercially developed works I have decided to     *
  14.  *    simply make it public domain to further its unrestricted use.    I     *
  15.  *    specifically  would  be  most happy to see this material become a     *
  16.  *    part of the standard Unix distributions by AT&T and the  Berkeley     *
  17.  *    Computer  Science  Research Group, and a standard part of the GNU     *
  18.  *    system from the Free Software Foundation.                  *
  19.  *                                          *
  20.  *    I would appreciate it, as a courtesy, if this notice is  left  in     *
  21.  *    all copies and derivative works.  Thank you.                  *
  22.  *                                          *
  23.  *    The author makes no warranty of any kind  with    respect  to  this     *
  24.  *    product  and  explicitly disclaims any implied warranties of mer-     *
  25.  *    chantability or fitness for any particular purpose.              *
  26.  *                                          *
  27.  ******************************************************************************
  28.  */
  29.  
  30.  
  31. /*
  32.  *  FILE
  33.  *
  34.  *    dbug.h      user include file for programs using the dbug package
  35.  *
  36.  *  SYNOPSIS
  37.  *
  38.  *    #include <local/dbug.h>
  39.  *
  40.  *  SCCS ID
  41.  *
  42.  *    @(#)dbug.h      1.13 7/17/89
  43.  *
  44.  *  DESCRIPTION
  45.  *
  46.  *    Programs which use the dbug package must include this file.
  47.  *    It contains the appropriate macros to call support routines
  48.  *    in the dbug runtime library.
  49.  *
  50.  *    To disable compilation of the macro expansions define the
  51.  *    preprocessor symbol "DBUG_OFF".  This will result in null
  52.  *    macros expansions so that the resulting code will be smaller
  53.  *    and faster.  (The difference may be smaller than you think
  54.  *    so this step is recommended only when absolutely necessary).
  55.  *    In general, tradeoffs between space and efficiency are
  56.  *    decided in favor of efficiency since space is seldom a
  57.  *    problem on the new machines).
  58.  *
  59.  *    All externally visible symbol names follow the pattern
  60.  *    "_db_xxx..xx_" to minimize the possibility of a dbug package
  61.  *    symbol colliding with a user defined symbol.
  62.  *
  63.  *    The DBUG_<N> style macros are obsolete and should not be used
  64.  *    in new code.  Macros to map them to instances of DBUG_PRINT
  65.  *    are provided for compatibility with older code.  They may go
  66.  *    away completely in subsequent releases.
  67.  *
  68.  *  AUTHOR
  69.  *
  70.  *    Fred Fish
  71.  *    (Currently employed by Motorola Computer Division, Tempe, Az.)
  72.  *    hao!noao!mcdsun!fnf
  73.  *    (602) 438-3614
  74.  *
  75.  */
  76.  
  77.  
  78. /*
  79.  *    Internally used dbug variables which must be global.
  80.  */
  81.  
  82. #include <stdio.h>
  83.  
  84. /*  ANSI prototypes added by Jonathan Springer, 1/6/93    */
  85. #ifndef DBUG_OFF
  86.     extern int _db_on_;         /* TRUE if debug currently enabled */
  87.     extern FILE *_db_fp_;        /* Current debug output stream */
  88.     extern char *_db_process_;        /* Name of current process */
  89.     extern int _db_keyword_ (char *);   /* Accept/reject keyword */
  90.     extern void _db_push_ (char *);     /* Push state, set up new state */
  91.     extern void _db_pop_ (void);        /* Pop previous debug state */
  92.     extern void _db_enter_ (char *, char *, int, char **, char **, int *, char ***);
  93.       /* New user function entered */
  94.     extern void _db_return_ (int, char **, char **, int *);
  95.       /* User function return */
  96.     extern void _db_pargs_ (int, char *);
  97.       /* Remember args for line */
  98.     extern void _db_doprnt_ (char *, ...);
  99.       /* Print debug output */
  100.     extern void _db_setjmp_ (void);     /* Save debugger environment */
  101.     extern void _db_longjmp_ (void);    /* Restore debugger environment */
  102. # endif
  103.  
  104.  
  105. /*
  106.  *    These macros provide a user interface into functions in the
  107.  *    dbug runtime support library.  They isolate users from changes
  108.  *    in the MACROS and/or runtime support.
  109.  *
  110.  *    The symbols "__LINE__" and "__FILE__" are expanded by the
  111.  *    preprocessor to the current source file line number and file
  112.  *    name respectively.
  113.  *
  114.  *    WARNING ---  Because the DBUG_ENTER macro allocates space on
  115.  *    the user function's stack, it must precede any executable
  116.  *    statements in the user function.
  117.  *
  118.  */
  119.  
  120. # ifdef DBUG_OFF
  121. #    define DBUG_ENTER(a1)
  122. #    define DBUG_RETURN(a1) return(a1)
  123. #    define DBUG_VOID_RETURN return
  124. #    define DBUG_EXECUTE(keyword,a1)
  125. #    define DBUG_PRINT(keyword,arglist)
  126. #    define DBUG_2(keyword,format)              /* Obsolete */
  127. #    define DBUG_3(keyword,format,a1)           /* Obsolete */
  128. #    define DBUG_4(keyword,format,a1,a2)        /* Obsolete */
  129. #    define DBUG_5(keyword,format,a1,a2,a3)     /* Obsolete */
  130. #    define DBUG_PUSH(a1)
  131. #    define DBUG_POP()
  132. #    define DBUG_PROCESS(a1)
  133. #    define DBUG_FILE (stderr)
  134. #    define DBUG_SETJMP setjmp
  135. #    define DBUG_LONGJMP longjmp
  136. # else
  137. #    define DBUG_ENTER(a) \
  138.     auto char *_db_func_; auto char *_db_file_; auto int _db_level_; \
  139.     auto char **_db_framep_; \
  140.     _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
  141.             &_db_framep_)
  142. #    define DBUG_LEAVE \
  143.     (_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
  144. #    define DBUG_RETURN(a1) return (DBUG_LEAVE, (a1))
  145. /*   define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}  Alternate form */
  146. #    define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
  147. #    define DBUG_EXECUTE(keyword,a1) \
  148.     {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
  149. #    define DBUG_PRINT(keyword,arglist) \
  150.     {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
  151. #    define DBUG_2(keyword,format) \
  152.     DBUG_PRINT(keyword,(format))            /* Obsolete */
  153. #    define DBUG_3(keyword,format,a1) \
  154.     DBUG_PRINT(keyword,(format,a1))         /* Obsolete */
  155. #    define DBUG_4(keyword,format,a1,a2) \
  156.     DBUG_PRINT(keyword,(format,a1,a2))      /* Obsolete */
  157. #    define DBUG_5(keyword,format,a1,a2,a3) \
  158.     DBUG_PRINT(keyword,(format,a1,a2,a3))   /* Obsolete */
  159. #    define DBUG_PUSH(a1) _db_push_ (a1)
  160. #    define DBUG_POP() _db_pop_ ()
  161. #    define DBUG_PROCESS(a1) (_db_process_ = a1)
  162. #    define DBUG_FILE (_db_fp_)
  163. #    define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
  164. #    define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
  165. # endif
  166.